package com.heyun.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.heyun.bean.HeyunDept;
import com.heyun.bean.HeyunEmp;
import com.heyun.bean.HeyunSalesPerf;
import com.heyun.dao.SalesPerfDao;
import com.heyun.service.SalesPerfService;
@Service
public class SalesPerfServiceImpl implements SalesPerfService {
	@Autowired
	private SalesPerfDao  salesperfdao;
	@Override
	public List<HeyunEmp> getEmpName() {
		List<HeyunEmp> emplist=salesperfdao.getEmpName();
		return emplist;
	}

	@Override
	public HeyunDept getDeptNameById(int deptId) {
		HeyunDept hyd=salesperfdao.getDeptNameById(deptId);
		return hyd;
	}

	@Override
	public void saveSalesPerf(HeyunSalesPerf hsp) {
		salesperfdao.saveSalesPerf(hsp);
		
	}

	@Override
	public Map<String, Object> findSalesPerf(int currentPage) {
		PageHelper.startPage(currentPage,3);//每一页显示三条数据
		//获取所有销售计划的集合
		List<HeyunSalesPerf> hsplist=salesperfdao.findSalesPerf();
		PageInfo<HeyunSalesPerf> p=new PageInfo<HeyunSalesPerf>(hsplist);
	
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("hsplist", hsplist);
		map.put("totalPage", p.getPages());
		
		return map;
	
	}

	@Override
	public HeyunEmp getEmpRealNameById(int empId) {
		// TODO Auto-generated method stub
		HeyunEmp emp=salesperfdao.getEmpRealNameById(empId);
		return emp;
	}

	@Override
	public HeyunSalesPerf getSalesPerfById(int salesPrefId) {
		HeyunSalesPerf  hsp=salesperfdao.getSalesPerfById(salesPrefId);
		
		return hsp;
	}

	@Override
	public void updateSalsPerfById(HeyunSalesPerf hsp) {
		// TODO Auto-generated method stub
		salesperfdao.updateSalsPerfById(hsp);
	}

	@Override
	public void deleteSalsPerfById(int salesPrefId) {
		// TODO Auto-generated method stub
		salesperfdao.deleteSalsPerfById(salesPrefId);
		
	}

	@Override
	public void deleteBatchSalesPerf(List<Integer> ids) {
		// TODO Auto-generated method stub
		salesperfdao.deleteBatchSalesPerf(ids);
		
	}

	@Override
	public Map<String, Object> findSalesPerfByName(int currentPage, String name) {
		// TODO Auto-generated method stub
		PageHelper.startPage(currentPage,3);//每一页显示三条数据
		List<HeyunSalesPerf> splist=salesperfdao.findSalesPerfByName(name);
		PageInfo<HeyunSalesPerf> p=new PageInfo<HeyunSalesPerf>(splist);
		for(HeyunSalesPerf hsp:splist){
			System.out.println("最后操作时间是====="+hsp.getFinalOperTime());
			System.out.println("备注是====="+hsp.getRemarks());
		}
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("splist", splist);
		map.put("totalPage", p.getPages());
		return map;
	
	}

}
